Skip to content

Make 2D line containment independent of coefficient scale - #305

Open
kaushikgunasekaren wants to merge 3 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-line2-containment-scale-nov15
Open

kaushikgunasekaren wants to merge 3 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-line2-containment-scale-nov15

Conversation

@kaushikgunasekaren

Copy link
Copy Markdown

Bug

Line2.contains() applies its tolerance to the raw homogeneous line equation. Multiplying the same line coefficients by a small nonzero number therefore accepts off-line points. This also makes Polygon2.intersects(line) report intersections for lines entirely outside the polygon.

Fix

Normalize the line coefficients by the Euclidean normal length before the residual test. The tolerance then measures perpendicular distance for Euclidean points and homogeneous points of unit weight. Public signatures and the existing tolerance parameter stay unchanged.

Validation

  • 22 regression/control cases cover axis-aligned and oblique lines, signed coefficient scales from 1e-20 to 1e20, on/off-line Euclidean and unit-weight homogeneous points, geometric tolerance boundaries, and polygon intersection callers.
  • Before: 8 failed, 14 passed. After: all 22 pass.
  • Full local suite: 588 passed, 3 skipped, 99 subtests passed; 29 baseline warnings. Pristine master25b19b3: 566 passed with the same skips/subtests/warnings.
  • Black23.10.0, fatal-error flake8 and git diff --check pass.

Distinct from #282's endpoint normalization in segment intersection and #298's 3D Plucker containment. AI assistance was used for investigation, implementation and tests. Validated locally without robot hardware.

Updated the contains method to normalize the line coefficients before calculating the dot product, improving accuracy in point containment tests.
Add tests for Line2 and Polygon2 scale invariance and geometric tolerance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant